import { reqCategoryList, reqGetBannerList, reqGetFloorList } from "@/axios/api/api.js"
// 游客身份模块UUID
import { getUUID } from '@/utils/uuid_token.js'
export default {
  namespaced: true,
  state: {
    // 三级导航数据
    categoryLists: [],
    // 轮播图数据
    bannerList: [],
    // 楼层轮播图数据
    floorList: [],
    // 游客身份模块UUID
    uuid_token: getUUID()
  },
  mutations: {
    GETCATEGORYLIST(state, arr) {
      // console.log(arr);
      state.categoryLists = arr
    },
    GETBANNERLIST(state, arr) {
      state.bannerList = arr
      // console.log('存储到state仓库中');
    },
    GETFLOORLIST(state, arr) {
      state.floorList = arr
      // console.log('floor存储到state仓库中');
    }
  },
  actions: {
    // 三级导航栏数据方法
    async getcategoryList(e) {
      let res = await reqCategoryList()
      // console.log(res);
      e.commit('GETCATEGORYLIST', res.data)
    },
    // 主页轮播图的数据
    async getBannerList({ commit }) {
      const res = await reqGetBannerList()
      // console.log(res);
      // console.log('发请求拿数据~');
      if (res.code !== 200) return
      commit('GETBANNERLIST', res.data)
    },
    // 楼层轮播图数据
    async getFloorList({ commit }) {
      let res = await reqGetFloorList()
      // console.log(res);
      if (res.code == 200) {
        commit('GETFLOORLIST', res.data)
      }
    }
  },
  getters: {}
}